package com.ququ.syb.common.pojo;

import com.ququ.syb.common.constant.AuditStatusConstant;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;

import java.text.SimpleDateFormat;
import java.util.*;

@Document(collection = "QualificationUrls")
public class QualificationUrls {
    @Id
    private String _id;
    private String accountId;       //生意宝账户Id
    private Integer bankId;            //生意宝提现银行卡Id
    private Boolean isLegalPerson;      //是否企业法人
    private String idCardFront;     //账户本人（或非法人时的被授权人）身份证正面照片
    private String idCardBack;      //账户本人（或非法人时的被授权人）身份证反面照片
    private String legalPersonIdCardFront;  //法人身份证正面
    private String legalPersonIdCardBack;   //法人身份证反面
    private Map<String,String> bankCardFront;   //结算银行卡正面照片
    private String personIdCard;    //账户本人（或非法人时的被授权人）手持身份证照片
    private String legalPersonIdCard;   //法人手持身份证照片
    private String personBankCard;    //账户本人（或非法人时的被授权人）手持银行卡照片
    private String legalPersonBankCard;   //法人手持银行卡照片
    private String companyLicense;  //营业执照照片
    private String companyTax;      //税务登记证照片（非三证合一）
    private String companyOrg;      //组织机构代码证（非三证合一）
    private String companyBank;     //银行开户许可证
    private String tradeLicense;    //行业特许证
    private String shopFace;        //店头照
    private String shopRoom;        //内景照
    private String cashier;         //收银台照片
    private String legalPersonLicenseShopFace;  //手持营业执照门头照合影（当门头照或店铺招牌与企业名称不符时）
    private String authorization;   //授权书
    private Integer personAuditStatus;    //个人审核总体状态： 0-未审核  1-审核通过  2-审核驳回
    private Integer companyAuditStatus;     //企业审核总体状态： 0-未审核 1-审核通过 2-审核驳回 3-申请审核
    private String lastModifyTime;      //最近更新时间
    private Map<String,Integer> auditStatusDetail;    //审核状态详情，字段名：状态值，0或null-未审核，1-审核通过，2-审核驳回
    private List<QualificationAuditLog> auditLogs;  //审核日志

    public String get_id() {
        return _id;
    }

    public void set_id(String _id) {
        this._id = _id;
    }

    public String getAccountId() {
        return accountId;
    }

    public void setAccountId(String accountId) {
        this.accountId = accountId;
    }

    public Integer getBankId() {
        return bankId;
    }

    public void setBankId(Integer bankId) {
        this.bankId = bankId;
    }

    public String getIdCardFront() {
        return idCardFront;
    }

    public Boolean getIsLegalPerson() {
        return isLegalPerson;
    }

    public void setIsLegalPerson(Boolean isLegalPerson) {
        this.isLegalPerson = isLegalPerson;
    }

    public void setIdCardFront(String idCardFront) {
        this.idCardFront = idCardFront;
        setQualificationAuditStatus("idCardFront",AuditStatusConstant.AUDIT_PASS);   //默认审核通过
    }

    public String getIdCardBack() {
        return idCardBack;
    }

    public void setIdCardBack(String idCardBack) {
        this.idCardBack = idCardBack;
        setQualificationAuditStatus("idCardBack",AuditStatusConstant.AUDIT_PASS);   //默认审核通过
    }

    public String getLegalPersonIdCardFront() {
        return legalPersonIdCardFront;
    }

    public void setLegalPersonIdCardFront(String legalPersonIdCardFront) {
        this.legalPersonIdCardFront = legalPersonIdCardFront;
        setQualificationAuditStatus("legalPersonIdCardFront",AuditStatusConstant.AUDIT_PASS);   //默认审核通过
    }

    public String getLegalPersonIdCardBack() {
        return legalPersonIdCardBack;
    }

    public void setLegalPersonIdCardBack(String legalPersonIdCardBack) {
        this.legalPersonIdCardBack = legalPersonIdCardBack;
        setQualificationAuditStatus("legalPersonIdCardBack",AuditStatusConstant.AUDIT_PASS);   //默认审核通过
    }

    public Map<String, String> getBankCardFront() {
        return bankCardFront;
    }

    public void setBankCardFront(Map<String, String> bankCardFront) {
        this.bankCardFront = bankCardFront;
    }

    public String getPersonIdCard() {
        return personIdCard;
    }

    public void setPersonIdCard(String personIdCard) {
        this.personIdCard = personIdCard;
        setQualificationAuditStatus("personIdCard",AuditStatusConstant.AUDIT_PASS);   //默认审核通过
    }

    public String getLegalPersonIdCard() {
        return legalPersonIdCard;
    }

    public void setLegalPersonIdCard(String legalPersonIdCard) {
        this.legalPersonIdCard = legalPersonIdCard;
        setQualificationAuditStatus("legalPersonIdCard",AuditStatusConstant.AUDIT_PASS);   //默认审核通过
    }

    public String getPersonBankCard() {
        return personBankCard;
    }

    public void setPersonBankCard(String personBankCard) {
        this.personBankCard = personBankCard;
        setQualificationAuditStatus("personBankCard",AuditStatusConstant.AUDIT_PASS);   //默认审核通过
    }

    public String getLegalPersonBankCard() {
        return legalPersonBankCard;
    }

    public void setLegalPersonBankCard(String legalPersonBankCard) {
        this.legalPersonBankCard = legalPersonBankCard;
        setQualificationAuditStatus("legalPersonBankCard",AuditStatusConstant.AUDIT_PASS);   //默认审核通过
    }

    public String getCompanyLicense() {
        return companyLicense;
    }

    public void setCompanyLicense(String companyLicense) {
        this.companyLicense = companyLicense;
        setQualificationAuditStatus("companyLicense",AuditStatusConstant.AUDIT_PASS);   //默认审核通过
    }

    public String getCompanyTax() {
        return companyTax;
    }

    public void setCompanyTax(String companyTax) {
        this.companyTax = companyTax;
        setQualificationAuditStatus("companyTax",AuditStatusConstant.AUDIT_PASS);   //默认审核通过
    }

    public String getCompanyOrg() {
        return companyOrg;
    }

    public void setCompanyOrg(String companyOrg) {
        this.companyOrg = companyOrg;
        setQualificationAuditStatus("companyOrg",AuditStatusConstant.AUDIT_PASS);   //默认审核通过
    }

    public String getCompanyBank() {
        return companyBank;
    }

    public void setCompanyBank(String companyBank) {
        this.companyBank = companyBank;
        setQualificationAuditStatus("companyBank",AuditStatusConstant.AUDIT_PASS);   //默认审核通过
    }

    public String getTradeLicense() {
        return tradeLicense;
    }

    public void setTradeLicense(String tradeLicense) {
        this.tradeLicense = tradeLicense;
        setQualificationAuditStatus("tradeLicense",AuditStatusConstant.AUDIT_PASS);   //默认审核通过
    }

    public String getShopFace() {
        return shopFace;
    }

    public void setShopFace(String shopFace) {
        this.shopFace = shopFace;
        setQualificationAuditStatus("shopFace",AuditStatusConstant.AUDIT_PASS);   //默认审核通过
    }

    public String getShopRoom() {
        return shopRoom;
    }

    public void setShopRoom(String shopRoom) {
        this.shopRoom = shopRoom;
        setQualificationAuditStatus("shopRoom",AuditStatusConstant.AUDIT_PASS);   //默认审核通过
    }

    public String getCashier() {
        return cashier;
    }

    public void setCashier(String cashier) {
        this.cashier = cashier;
        setQualificationAuditStatus("cashier",AuditStatusConstant.AUDIT_PASS);   //默认审核通过
    }

    public String getLegalPersonLicenseShopFace() {
        return legalPersonLicenseShopFace;
    }

    public void setLegalPersonLicenseShopFace(String legalPersonLicenseShopFace) {
        this.legalPersonLicenseShopFace = legalPersonLicenseShopFace;
        setQualificationAuditStatus("legalPersonLicenseShopFace",AuditStatusConstant.AUDIT_PASS);   //默认审核通过
    }

    public String getAuthorization() {
        return authorization;
    }

    public void setAuthorization(String authorization) {
        this.authorization = authorization;
        setQualificationAuditStatus("authorization",AuditStatusConstant.AUDIT_PASS);   //默认审核通过
    }

    public Integer getPersonAuditStatus() {
        return personAuditStatus;
    }

    public void setPersonAuditStatus(Integer personAuditStatus) {
        this.personAuditStatus = personAuditStatus;
    }

    public Integer getCompanyAuditStatus() {
        return companyAuditStatus;
    }

    public void setCompanyAuditStatus(Integer companyAuditStatus) {
        this.companyAuditStatus = companyAuditStatus;
    }

    public Map<String, Integer> getAuditStatusDetail() {
        return auditStatusDetail;
    }

    public void setAuditStatusDetail(Map<String, Integer> auditStatusDetail) {
        this.auditStatusDetail = auditStatusDetail;
    }

    public List<QualificationAuditLog> getAuditLogs() {
        return auditLogs;
    }

    public void setAuditLogs(List<QualificationAuditLog> auditLogs) {
        this.auditLogs = auditLogs;
    }

    public void setBankCardUrl(String bankCardNo,String bankCardUrl){
        if (bankCardFront == null)
            bankCardFront = new HashMap<>();
        bankCardFront.put(bankCardNo,bankCardUrl);
        setQualificationAuditStatus(bankCardNo,AuditStatusConstant.AUDIT_PASS);   //默认审核通过
    }

    public String getBankCardUrl(String bankCardNo){
        if (bankCardFront == null)
            return null;
        else
            return bankCardFront.get(bankCardNo);
    }

    public void addAuditLog(String auditor,int status,String auditResult){
        QualificationAuditLog qualificationAuditLog = new QualificationAuditLog();
        qualificationAuditLog.setAudittime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
        qualificationAuditLog.setAuditor(auditor);
        qualificationAuditLog.setAuditresult(auditResult);
        qualificationAuditLog.setStatus(status);
        if (auditLogs == null)
            auditLogs = new ArrayList<>();
        auditLogs.add(0,qualificationAuditLog);
    }

    public void setQualificationAuditStatus(String qualification,Integer status){
        if (auditStatusDetail == null)
            auditStatusDetail = new HashMap<>();
        auditStatusDetail.put(qualification,status);
    }


    public String getLastModifyTime() {
        return lastModifyTime;
    }

    public void setLastModifyTime(String lastModifyTime) {
        this.lastModifyTime = lastModifyTime;
    }

    @Override
    public String toString() {
        return "QualificationUrls{" +
                "_id='" + _id + '\'' +
                ", accountId='" + accountId + '\'' +
                ", bankId=" + bankId +
                ", isLegalPerson=" + isLegalPerson +
                ", idCardFront='" + idCardFront + '\'' +
                ", idCardBack='" + idCardBack + '\'' +
                ", legalPersonIdCardFront='" + legalPersonIdCardFront + '\'' +
                ", legalPersonIdCardBack='" + legalPersonIdCardBack + '\'' +
                ", bankCardFront=" + bankCardFront +
                ", personIdCard='" + personIdCard + '\'' +
                ", legalPersonIdCard='" + legalPersonIdCard + '\'' +
                ", personBankCard='" + personBankCard + '\'' +
                ", legalPersonBankCard='" + legalPersonBankCard + '\'' +
                ", companyLicense='" + companyLicense + '\'' +
                ", companyTax='" + companyTax + '\'' +
                ", companyOrg='" + companyOrg + '\'' +
                ", companyBank='" + companyBank + '\'' +
                ", tradeLicense='" + tradeLicense + '\'' +
                ", shopFace='" + shopFace + '\'' +
                ", shopRoom='" + shopRoom + '\'' +
                ", cashier='" + cashier + '\'' +
                ", legalPersonLicenseShopFace='" + legalPersonLicenseShopFace + '\'' +
                ", authorization='" + authorization + '\'' +
                ", personAuditStatus=" + personAuditStatus +
                ", companyAuditStatus=" + companyAuditStatus +
                ", lastModifyTime='" + lastModifyTime + '\'' +
                ", auditStatusDetail=" + auditStatusDetail +
                ", auditLogs=" + auditLogs +
                '}';
    }
}
